home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Online / PHP / lib / php / build / acinclude.m4 next >
Encoding:
M4 Source File  |  2001-06-06  |  22.0 KB  |  970 lines

  1. dnl $Id: acinclude.m4,v 1.121 2001/02/21 07:39:13 sas Exp $
  2. dnl
  3. dnl This file contains local autoconf functions.
  4.  
  5. sinclude(dynlib.m4)
  6.  
  7. AC_DEFUN(PHP_SETUP_OPENSSL,[
  8.   if test "$PHP_OPENSSL" = "no"; then
  9.     PHP_OPENSSL="/usr/local/ssl /usr/local /usr /usr/local/openssl"
  10.   fi
  11.  
  12.   for i in $PHP_OPENSSL; do
  13.     if test -r $i/include/openssl/evp.h; then
  14.       OPENSSL_DIR=$i
  15.       OPENSSL_INC=$i/include
  16.     fi
  17.   done
  18.  
  19.   if test -z "$OPENSSL_DIR"; then
  20.     AC_MSG_ERROR(Cannot find OpenSSL's <evp.h>)
  21.   fi
  22.  
  23.   old_CPPFLAGS=$CPPFLAGS
  24.   CPPFLAGS="-I$OPENSSL_INC"
  25.   AC_MSG_CHECKING(for OpenSSL version)
  26.   AC_EGREP_CPP(yes,[
  27.   #include <openssl/opensslv.h>
  28.   #if OPENSSL_VERSION_NUMBER >= 0x0090500fL
  29.   yes
  30.   #endif
  31.   ],[
  32.     AC_MSG_RESULT(>= 0.9.5)
  33.   ],[
  34.     AC_MSG_ERROR(OpenSSL version 0.9.5 or greater required.)
  35.   ])
  36.   CPPFLAGS=$old_CPPFLAGS
  37.  
  38.   AC_ADD_LIBPATH($OPENSSL_DIR/lib)
  39.  
  40.   AC_CHECK_LIB(crypto, CRYPTO_free, [
  41.     AC_ADD_LIBRARY(crypto)
  42.   ],[
  43.     AC_MSG_ERROR(libcrypto not found!)
  44.   ])
  45.  
  46.   AC_CHECK_LIB(ssl, SSL_CTX_set_ssl_version, [
  47.     AC_ADD_LIBRARY(ssl)
  48.   ],[
  49.     AC_MSG_ERROR(libssl not found!)
  50.   ])
  51.   AC_ADD_INCLUDE($OPENSSL_INC)
  52. ])
  53.  
  54. dnl PHP_EVAL_LIBLINE(LINE, SHARED-LIBADD)
  55. dnl
  56. dnl Use this macro, if you need to add libraries and or library search
  57. dnl paths to the PHP build system which are only given in compiler
  58. dnl notation.
  59. dnl
  60. AC_DEFUN(PHP_EVAL_LIBLINE,[
  61.   for ac_i in $1; do
  62.     case "$ac_i" in
  63.     -l*)
  64.       ac_ii=`echo $ac_i|cut -c 3-`
  65.       AC_ADD_LIBRARY($ac_ii,,$2)
  66.     ;;
  67.     -L*)
  68.       ac_ii=`echo $ac_i|cut -c 3-`
  69.       AC_ADD_LIBPATH($ac_ii,$2)
  70.     ;;
  71.     esac
  72.   done
  73. ])
  74.  
  75. dnl PHP_EVAL_INCLINE(LINE)
  76. dnl
  77. dnl Use this macro, if you need to add header search paths to the PHP
  78. dnl build system which are only given in compiler notation.
  79. dnl
  80. AC_DEFUN(PHP_EVAL_INCLINE,[
  81.   for ac_i in $1; do
  82.     case "$ac_i" in
  83.     -I*)
  84.       ac_ii=`echo $ac_i|cut -c 3-`
  85.       AC_ADD_INCLUDE($ac_ii)
  86.     ;;
  87.     esac
  88.   done
  89. ])
  90.     
  91. AC_DEFUN(PHP_READDIR_R_TYPE,[
  92.   dnl HAVE_READDIR_R is also defined by libmysql
  93.   AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
  94.   if test "$ac_cv_func_readdir_r" = "yes"; then
  95.   AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
  96.     AC_TRY_RUN([
  97. #define _REENTRANT
  98. #include <sys/types.h>
  99. #include <dirent.h>
  100.  
  101. #ifndef PATH_MAX
  102. #define PATH_MAX 1024
  103. #endif
  104.  
  105. main() {
  106.     DIR *dir;
  107.     char entry[sizeof(struct dirent)+PATH_MAX];
  108.     struct dirent *pentry = (struct dirent *) &entry;
  109.  
  110.     dir = opendir("/");
  111.     if (!dir) 
  112.         exit(1);
  113.     if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
  114.         exit(0);
  115.     exit(1);
  116. }
  117.     ],[
  118.       ac_cv_what_readdir_r=POSIX
  119.     ],[
  120.       AC_TRY_CPP([
  121. #define _REENTRANT
  122. #include <sys/types.h>
  123. #include <dirent.h>
  124. int readdir_r(DIR *, struct dirent *);
  125.         ],[
  126.           ac_cv_what_readdir_r=old-style
  127.         ],[
  128.           ac_cv_what_readdir_r=none
  129.       ])
  130.     ],[
  131.       ac_cv_what_readdir_r=none
  132.    ])
  133.   ])
  134.     case "$ac_cv_what_readdir_r" in
  135.     POSIX)
  136.       AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
  137.     old-style)
  138.       AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
  139.     esac
  140.   fi
  141. ])
  142.  
  143. AC_DEFUN(PHP_SHLIB_SUFFIX_NAME,[
  144.   PHP_SUBST(SHLIB_SUFFIX_NAME)
  145.   SHLIB_SUFFIX_NAME=so
  146.   case "$host_alias" in
  147.   *hpux*)
  148.     SHLIB_SUFFIX_NAME=sl
  149.     ;;
  150.   esac
  151. ])
  152.  
  153. AC_DEFUN(PHP_DEBUG_MACRO,[
  154.   DEBUG_LOG="$1"
  155.   cat >$1 <<X
  156. CONFIGURE:  $CONFIGURE_COMMAND
  157. CC:         $CC
  158. CFLAGS:     $CFLAGS
  159. CPPFLAGS:   $CPPFLAGS
  160. CXX:        $CXX
  161. CXXFLAGS:   $CXXFLAGS
  162. INCLUDES:   $INCLUDES
  163. LDFLAGS:    $LDFLAGS
  164. LIBS:       $LIBS
  165. DLIBS:      $DLIBS
  166. SAPI:       $PHP_SAPI
  167. PHP_RPATHS: $PHP_RPATHS
  168. uname -a:   `uname -a`
  169.  
  170. X
  171.     cat >conftest.$ac_ext <<X
  172. main()
  173. {
  174.   exit(0);
  175. }
  176. X
  177.     (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
  178.     rm -fr conftest*
  179. ])
  180.     
  181. AC_DEFUN(PHP_MISSING_TIME_R_DECL,[
  182.   AC_MSG_CHECKING(for missing declarations of reentrant functions)
  183.   AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
  184.     :
  185.   ],[
  186.     AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
  187.   ])
  188.   AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
  189.     :
  190.   ],[
  191.     AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
  192.   ])
  193.   AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
  194.     :
  195.   ],[
  196.     AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
  197.   ])
  198.   AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
  199.     :
  200.   ],[
  201.     AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
  202.   ])
  203.   AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
  204.     :
  205.   ],[
  206.     AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
  207.   ])
  208.   AC_MSG_RESULT(done)
  209. ])
  210.  
  211. dnl
  212. dnl PHP_LIBGCC_LIBPATH(gcc)
  213. dnl Stores the location of libgcc in libgcc_libpath
  214. dnl
  215. AC_DEFUN(PHP_LIBGCC_LIBPATH,[
  216.   changequote({,})
  217.   libgcc_libpath="`$1 --print-libgcc-file-name|sed 's%/*[^/][^/]*$%%'`"
  218.   changequote([,])
  219. ])
  220.  
  221. AC_DEFUN(PHP_ARG_ANALYZE,[
  222. case "[$]$1" in
  223. shared,*)
  224.   ext_output="yes, shared"
  225.   ext_shared=yes
  226.   $1=`echo "[$]$1"|sed 's/^shared,//'`
  227.   ;;
  228. shared)
  229.   ext_output="yes, shared"
  230.   ext_shared=yes
  231.   $1=yes
  232.   ;;
  233. no)
  234.   ext_output="no"
  235.   ext_shared=no
  236.   ;;
  237. *)
  238.   ext_output="yes"
  239.   ext_shared=no
  240.   ;;
  241. esac
  242.  
  243. if test "$php_always_shared" = "yes"; then
  244.   ext_output="yes, shared"
  245.   ext_shared=yes
  246.   test "[$]$1" = "no" && $1=yes
  247. fi
  248.  
  249. AC_MSG_RESULT($ext_output)
  250. ])
  251.  
  252. dnl
  253. dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val])
  254. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  255. dnl default-val defaults to no. 
  256. dnl
  257. AC_DEFUN(PHP_ARG_WITH,[
  258. PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_))
  259. ])
  260.  
  261. AC_DEFUN(PHP_REAL_ARG_WITH,[
  262. AC_MSG_CHECKING($2)
  263. AC_ARG_WITH($1,[$3],$5=[$]withval,$5=ifelse($4,,no,$4))
  264. PHP_ARG_ANALYZE($5)
  265. ])
  266.  
  267. dnl
  268. dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val])
  269. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  270. dnl default-val defaults to no. 
  271. dnl
  272. AC_DEFUN(PHP_ARG_ENABLE,[
  273. PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_))
  274. ])
  275.  
  276. AC_DEFUN(PHP_REAL_ARG_ENABLE,[
  277. AC_MSG_CHECKING($2)
  278. AC_ARG_ENABLE($1,[$3],$5=[$]enableval,$5=ifelse($4,,no,$4))
  279. PHP_ARG_ANALYZE($5)
  280. ])
  281.  
  282. AC_DEFUN(PHP_MODULE_PTR,[
  283.   EXTRA_MODULE_PTRS="$EXTRA_MODULE_PTRS $1,"
  284. ])
  285.  
  286. AC_DEFUN(PHP_CONFIG_NICE,[
  287.   rm -f $1
  288.   cat >$1<<EOF
  289. #! /bin/sh
  290. #
  291. # Created by configure
  292.  
  293. EOF
  294.  
  295.   for arg in [$]0 "[$]@"; do
  296.     echo "\"[$]arg\" \\" >> $1
  297.   done
  298.   echo '"[$]@"' >> $1
  299.   chmod +x $1
  300. ])
  301.  
  302. AC_DEFUN(PHP_TIME_R_TYPE,[
  303. AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
  304. AC_TRY_RUN([
  305. #include <time.h>
  306. #include <stdlib.h>
  307.  
  308. main() {
  309. char buf[27];
  310. struct tm t;
  311. time_t old = 0;
  312. int r, s;
  313.  
  314. s = gmtime_r(&old, &t);
  315. r = (int) asctime_r(&t, buf, 26);
  316. if (r == s && s == 0) exit(0);
  317. exit(1);
  318. }
  319. ],[
  320.   ac_cv_time_r_type=hpux
  321. ],[
  322.   ac_cv_time_r_type=POSIX
  323. ],[
  324.   ac_cv_time_r_type=POSIX
  325. ])
  326. ])
  327. if test "$ac_cv_time_r_type" = "hpux"; then
  328.   AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x])
  329. fi
  330. ])
  331.  
  332. AC_DEFUN(PHP_SUBST,[
  333.   PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
  334. ])
  335.  
  336. AC_DEFUN(PHP_SUBST_OLD,[
  337.   PHP_SUBST($1)
  338.   AC_SUBST($1)
  339. ])
  340.  
  341. AC_DEFUN(PHP_FAST_OUTPUT,[
  342.   PHP_FAST_OUTPUT_FILES="$PHP_FAST_OUTPUT_FILES $1"
  343. ])
  344.  
  345. AC_DEFUN(PHP_MKDIR_P_CHECK,[
  346.   AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
  347.     test -d conftestdir && rm -rf conftestdir
  348.     mkdir -p conftestdir/somedir >/dev/null 2>&1
  349.     if test -d conftestdir/somedir; then
  350.       ac_cv_mkdir_p=yes
  351.     else
  352.       ac_cv_mkdir_p=no
  353.     fi
  354.     rm -rf conftestdir
  355.   ])
  356. ])
  357.  
  358. AC_DEFUN(PHP_GEN_CONFIG_VARS,[
  359.   PHP_MKDIR_P_CHECK
  360.   echo creating config_vars.mk
  361.   > config_vars.mk
  362.   for i in $PHP_VAR_SUBST; do
  363.     eval echo "$i = \$$i" >> config_vars.mk
  364.   done
  365. ])
  366.  
  367. AC_DEFUN(PHP_GEN_MAKEFILES,[
  368.   $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $1
  369. ])
  370.  
  371. AC_DEFUN(PHP_TM_GMTOFF,[
  372. AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
  373. [AC_TRY_COMPILE([#include <sys/types.h>
  374. #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
  375.   ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
  376.  
  377. if test "$ac_cv_struct_tm_gmtoff" = yes; then
  378.   AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
  379. fi
  380. ])
  381.  
  382. dnl PHP_CONFIGURE_PART(MESSAGE)
  383. dnl Idea borrowed from mm
  384. AC_DEFUN(PHP_CONFIGURE_PART,[
  385.   AC_MSG_RESULT()
  386.   AC_MSG_RESULT(${T_MD}$1${T_ME})
  387. ])
  388.  
  389. AC_DEFUN(PHP_PROG_SENDMAIL,[
  390. AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib)
  391. if test -n "$PROG_SENDMAIL"; then
  392.   AC_DEFINE(HAVE_SENDMAIL,1,[whether you have sendmail])
  393. fi
  394. ])
  395.  
  396. AC_DEFUN(PHP_RUNPATH_SWITCH,[
  397. dnl check for -R, etc. switch
  398. AC_MSG_CHECKING(if compiler supports -R)
  399. AC_CACHE_VAL(php_cv_cc_dashr,[
  400.     SAVE_LIBS="${LIBS}"
  401.     LIBS="-R /usr/lib ${LIBS}"
  402.     AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
  403.     LIBS="${SAVE_LIBS}"])
  404. AC_MSG_RESULT($php_cv_cc_dashr)
  405. if test $php_cv_cc_dashr = "yes"; then
  406.     ld_runpath_switch="-R"
  407. else
  408.     AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
  409.     AC_CACHE_VAL(php_cv_cc_rpath,[
  410.         SAVE_LIBS="${LIBS}"
  411.         LIBS="-Wl,-rpath,/usr/lib ${LIBS}"
  412.         AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
  413.         LIBS="${SAVE_LIBS}"])
  414.     AC_MSG_RESULT($php_cv_cc_rpath)
  415.     if test $php_cv_cc_rpath = "yes"; then
  416.         ld_runpath_switch="-Wl,-rpath,"
  417.     else
  418.         dnl something innocuous
  419.         ld_runpath_switch="-L"
  420.     fi
  421. fi
  422. ])
  423.  
  424. AC_DEFUN(PHP_STRUCT_FLOCK,[
  425. AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
  426.     AC_TRY_COMPILE([
  427. #include <unistd.h>
  428. #include <fcntl.h>
  429.         ],
  430.         [struct flock x;],
  431.         [
  432.           ac_cv_struct_flock=yes
  433.         ],[
  434.           ac_cv_struct_flock=no
  435.         ])
  436. )
  437. if test "$ac_cv_struct_flock" = "yes" ; then
  438.     AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
  439. fi
  440. ])
  441.  
  442. AC_DEFUN(PHP_SOCKLEN_T,[
  443. AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
  444.   AC_TRY_COMPILE([
  445. #include <sys/types.h>
  446. #include <sys/socket.h>
  447. ],[
  448. socklen_t x;
  449. ],[
  450.   ac_cv_socklen_t=yes
  451. ],[
  452.   ac_cv_socklen_t=no
  453. ]))
  454. if test "$ac_cv_socklen_t" = "yes"; then
  455.   AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
  456. fi
  457. ])
  458.  
  459. dnl
  460. dnl PHP_SET_SYM_FILE(path)
  461. dnl
  462. dnl set the path of the file which contains the symbol export list
  463. dnl
  464. AC_DEFUN(PHP_SET_SYM_FILE,
  465. [
  466.   PHP_SYM_FILE="$1"
  467. ])
  468.  
  469. dnl
  470. dnl PHP_BUILD_THREAD_SAFE
  471. dnl
  472. AC_DEFUN(PHP_BUILD_THREAD_SAFE,[
  473.   enable_experimental_zts=yes
  474.   if test "$pthreads_working" != "yes"; then
  475.     AC_MSG_ERROR(ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.)
  476.   fi
  477. ])
  478.  
  479. AC_DEFUN(PHP_REQUIRE_CXX,[
  480.   if test -z "$php_cxx_done"; then
  481.     AC_PROG_CXX
  482.     AC_PROG_CXXCPP
  483.     php_cxx_done=yes
  484.   fi
  485. ])
  486.  
  487. dnl
  488. dnl PHP_BUILD_SHARED
  489. dnl
  490. AC_DEFUN(PHP_BUILD_SHARED,[
  491.   php_build_target=shared
  492. ])
  493.  
  494. dnl
  495. dnl PHP_BUILD_STATIC
  496. dnl
  497. AC_DEFUN(PHP_BUILD_STATIC,[
  498.   php_build_target=static
  499. ])
  500.  
  501. dnl
  502. dnl PHP_BUILD_PROGRAM
  503. dnl
  504. AC_DEFUN(PHP_BUILD_PROGRAM,[
  505.   php_build_target=program
  506. ])
  507.  
  508. dnl
  509. dnl AC_PHP_ONCE(namespace, variable, code)
  510. dnl
  511. dnl execute code, if variable is not set in namespace
  512. dnl
  513. AC_DEFUN(AC_PHP_ONCE,[
  514.   changequote({,})
  515.   unique=`echo $2|sed 's/[^a-zA-Z0-9]/_/g'`
  516.   changequote([,])
  517.   cmd="echo $ac_n \"\$$1$unique$ac_c\""
  518.   if test -n "$unique" && test "`eval $cmd`" = "" ; then
  519.     eval "$1$unique=set"
  520.     $3
  521.   fi
  522. ])
  523.  
  524. dnl
  525. dnl AC_EXPAND_PATH(path, variable)
  526. dnl
  527. dnl expands path to an absolute path and assigns it to variable
  528. dnl
  529. AC_DEFUN(AC_EXPAND_PATH,[
  530.   if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
  531.     $2="$1"
  532.   else
  533.     changequote({,})
  534.     ep_dir="`echo $1|sed 's%/*[^/][^/]*/*$%%'`"
  535.     changequote([,])
  536.     ep_realdir="`(cd \"$ep_dir\" && pwd)`"
  537.     $2="$ep_realdir/`basename \"$1\"`"
  538.   fi
  539. ])
  540.  
  541. dnl
  542. dnl AC_ADD_LIBPATH(path[, shared-libadd])
  543. dnl
  544. dnl add a library to linkpath/runpath
  545. dnl
  546. AC_DEFUN(AC_ADD_LIBPATH,[
  547.   if test "$1" != "/usr/lib"; then
  548.     AC_EXPAND_PATH($1, ai_p)
  549.     if test "$ext_shared" = "yes" && test -n "$2"; then
  550.       $2="-R$1 -L$1 [$]$2"
  551.     else
  552.       AC_PHP_ONCE(LIBPATH, $ai_p, [
  553.         test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$ai_p"
  554.         LDFLAGS="$LDFLAGS -L$ai_p"
  555.         PHP_RPATHS="$PHP_RPATHS $ai_p"
  556.       ])
  557.     fi
  558.   fi
  559. ])
  560.  
  561. dnl
  562. dnl AC_BUILD_RPATH()
  563. dnl
  564. dnl builds RPATH from PHP_RPATHS
  565. dnl
  566. AC_DEFUN(AC_BUILD_RPATH,[
  567.   if test "$PHP_RPATH" = "yes" && test -n "$PHP_RPATHS"; then
  568.     OLD_RPATHS="$PHP_RPATHS"
  569.     PHP_RPATHS=""
  570.     for i in $OLD_RPATHS; do
  571.       PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
  572.       PHP_RPATHS="$PHP_RPATHS -R $i"
  573.       NATIVE_RPATHS="$NATIVE_RPATHS ${ld_runpath_switch}$i"
  574.     done
  575.   fi
  576. ])
  577.  
  578. dnl
  579. dnl AC_ADD_INCLUDE(path)
  580. dnl
  581. dnl add a include path
  582. dnl
  583. AC_DEFUN(AC_ADD_INCLUDE,[
  584.   if test "$1" != "/usr/include"; then
  585.     AC_EXPAND_PATH($1, ai_p)
  586.     AC_PHP_ONCE(INCLUDEPATH, $ai_p, [
  587.       INCLUDES="$INCLUDES -I$ai_p"
  588.     ])
  589.   fi
  590. ])
  591.  
  592. AC_DEFUN(PHP_X_ADD_LIBRARY,[
  593.   ifelse($2,,$3="-l$1 [$]$3", $3="[$]$3 -l$1")
  594. ])
  595.  
  596. dnl
  597. dnl AC_ADD_LIBRARY(library[, append[, shared-libadd]])
  598. dnl
  599. dnl add a library to the link line
  600. dnl
  601. AC_DEFUN(AC_ADD_LIBRARY,[
  602.  case "$1" in
  603.  c|c_r|pthread*) ;;
  604.  *)
  605. ifelse($3,,[
  606.    PHP_X_ADD_LIBRARY($1,$2,LIBS)
  607. ],[
  608.    if test "$ext_shared" = "yes"; then
  609.      PHP_X_ADD_LIBRARY($1,$2,$3)
  610.    else
  611.      AC_ADD_LIBRARY($1,$2)
  612.    fi
  613. ])
  614.   ;;
  615.   esac
  616. ])
  617.  
  618. dnl
  619. dnl AC_ADD_LIBRARY_DEFER(library[, append])
  620. dnl
  621. dnl add a library to the link line (deferred)
  622. AC_DEFUN(AC_ADD_LIBRARY_DEFER,[
  623.   ifelse($#, 1, DLIBS="-l$1 $DLIBS", DLIBS="$DLIBS -l$1")
  624. ])
  625.  
  626. dnl
  627. dnl AC_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
  628. dnl
  629. dnl add a library to the link line and path to linkpath/runpath.
  630. dnl if shared-libadd is not empty and $ext_shared is yes,
  631. dnl shared-libadd will be assigned the library information
  632. dnl
  633. AC_DEFUN(AC_ADD_LIBRARY_WITH_PATH,[
  634. ifelse($3,,[
  635.   if test -n "$2"; then
  636.     AC_ADD_LIBPATH($2)
  637.   fi
  638.   AC_ADD_LIBRARY($1)
  639. ],[
  640.   if test "$ext_shared" = "yes"; then
  641.     $3="-l$1 [$]$3"
  642.     if test -n "$2"; then
  643.       AC_ADD_LIBPATH($2,$3)
  644.     fi
  645.   else
  646.     AC_ADD_LIBRARY_WITH_PATH($1,$2)
  647.   fi
  648. ])
  649. ])
  650.  
  651. dnl
  652. dnl AC_ADD_LIBRARY_DEFER_WITH_PATH(library, path)
  653. dnl
  654. dnl add a library to the link line (deferred)
  655. dnl and path to linkpath/runpath (not deferred)
  656. dnl
  657. AC_DEFUN(AC_ADD_LIBRARY_DEFER_WITH_PATH,[
  658.   AC_ADD_LIBPATH($2)
  659.   AC_ADD_LIBRARY_DEFER($1)
  660. ])
  661.  
  662. AC_DEFUN(AM_SET_LIBTOOL_VARIABLE,[
  663.   LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
  664. ])
  665.  
  666. dnl
  667. dnl Check for cc option
  668. dnl
  669. AC_DEFUN(AC_CHECK_CC_OPTION,[
  670.   echo "main(){return 0;}" > conftest.$ac_ext
  671.   opt="$1"
  672.   changequote({,})
  673.   var=`echo $opt|sed 's/[^a-zA-Z0-9]/_/g'`
  674.   changequote([,])
  675.   AC_MSG_CHECKING([if compiler supports -$1 really])
  676.   ac_php_compile="${CC-cc} -$opt -o conftest $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1"
  677.   if eval $ac_php_compile 2>&1 | egrep "$opt" > /dev/null 2>&1 ; then
  678.     eval php_cc_$var=no
  679.     AC_MSG_RESULT(no)
  680.   else
  681.     if eval ./conftest 2>/dev/null ; then
  682.       eval php_cc_$var=yes
  683.       AC_MSG_RESULT(yes)
  684.     else
  685.       eval php_cc_$var=no
  686.       AC_MSG_RESULT(no)
  687.     fi
  688.   fi
  689. ])
  690.  
  691. AC_DEFUN(PHP_REGEX,[
  692.  
  693. if test "$REGEX_TYPE" = "php"; then
  694.   REGEX_LIB=regex/libregex.la
  695.   REGEX_DIR=regex
  696.   AC_DEFINE(HSREGEX,1,[ ])
  697.   AC_DEFINE(REGEX,1,[ ])
  698.   PHP_FAST_OUTPUT(regex/Makefile)
  699. elif test "$REGEX_TYPE" = "system"; then
  700.   AC_DEFINE(REGEX,0,[ ])
  701. fi
  702.  
  703. AC_MSG_CHECKING(which regex library to use)
  704. AC_MSG_RESULT($REGEX_TYPE)
  705.  
  706. PHP_SUBST(REGEX_DIR)
  707. PHP_SUBST(REGEX_LIB)
  708. PHP_SUBST(HSREGEX)
  709. ])
  710.  
  711. dnl
  712. dnl See if we have broken header files like SunOS has.
  713. dnl
  714. AC_DEFUN(AC_MISSING_FCLOSE_DECL,[
  715.   AC_MSG_CHECKING([for fclose declaration])
  716.   AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
  717.     AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
  718.     AC_MSG_RESULT(ok)
  719.   ],[
  720.     AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
  721.     AC_MSG_RESULT(missing)
  722.   ])
  723. ])
  724.  
  725. dnl
  726. dnl Check for broken sprintf()
  727. dnl
  728. AC_DEFUN(AC_BROKEN_SPRINTF,[
  729.   AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
  730.     AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
  731.       ac_cv_broken_sprintf=no
  732.     ],[
  733.       ac_cv_broken_sprintf=yes
  734.     ],[
  735.       ac_cv_broken_sprintf=no
  736.     ])
  737.   ])
  738.   if test "$ac_cv_broken_sprintf" = "yes"; then
  739.     AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [ ])
  740.   else
  741.     AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [ ])
  742.   fi
  743. ])
  744.  
  745. dnl
  746. dnl PHP_EXTENSION(extname [, shared])
  747. dnl
  748. dnl Includes an extension in the build.
  749. dnl
  750. dnl "extname" is the name of the ext/ subdir where the extension resides
  751. dnl "shared" can be set to "shared" or "yes" to build the extension as
  752. dnl a dynamically loadable library.
  753. dnl
  754. AC_DEFUN(PHP_EXTENSION,[
  755.   EXT_SUBDIRS="$EXT_SUBDIRS $1"
  756.   
  757.   if test -d "$abs_srcdir/ext/$1"; then
  758. dnl ---------------------------------------------- Internal Module
  759.     ext_builddir="ext/$1"
  760.     ext_srcdir="$abs_srcdir/ext/$1"
  761.   else
  762. dnl ---------------------------------------------- External Module
  763.     ext_builddir="."
  764.     ext_srcdir="$abs_srcdir"
  765.   fi
  766.  
  767.   if test "$2" != "shared" && test "$2" != "yes"; then
  768. dnl ---------------------------------------------- Static module
  769.     LIB_BUILD($ext_builddir)
  770.     EXT_LTLIBS="$EXT_LTLIBS $ext_builddir/lib$1.la"
  771.     EXT_STATIC="$EXT_STATIC $1"
  772.   else 
  773. dnl ---------------------------------------------- Shared module
  774.     LIB_BUILD($ext_builddir,yes)
  775.     AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z-,A-Z_), 1, Whether to build $1 as dynamic module)
  776.   fi
  777.  
  778.   PHP_FAST_OUTPUT($ext_builddir/Makefile)
  779. ])
  780.  
  781. dnl
  782. dnl Solaris requires main code to be position independent in order
  783. dnl to let shared objects find symbols.  Weird.  Ugly.
  784. dnl
  785. dnl Must be run after all --with-NN options that let the user
  786. dnl choose dynamic extensions, and after the gcc test.
  787. dnl
  788. AC_DEFUN(PHP_SOLARIS_PIC_WEIRDNESS,[
  789.   AC_MSG_CHECKING(whether -fPIC is required)
  790.   if test "$EXT_SHARED" != ""; then
  791.     os=`uname -sr 2>/dev/null`
  792.     case "$os" in
  793.         "SunOS 5.6"|"SunOS 5.7")
  794.           case "$CC" in
  795.         gcc*|egcs*) CFLAGS="$CFLAGS -fPIC";;
  796.         *) CFLAGS="$CFLAGS -fpic";;
  797.       esac
  798.       AC_MSG_RESULT(yes);;
  799.     *)
  800.       AC_MSG_RESULT(no);;
  801.     esac
  802.   else
  803.     AC_MSG_RESULT(no)
  804.   fi
  805. ])
  806.  
  807. dnl
  808. dnl Checks whether $withval is "shared" or starts with "shared,XXX"
  809. dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
  810. dnl from $withval.
  811. dnl
  812. AC_DEFUN(PHP_WITH_SHARED,[
  813.     case $withval in
  814.     shared)
  815.         shared=yes
  816.         withval=yes
  817.         ;;
  818.     shared,*)
  819.         shared=yes
  820.         withval=`echo $withval | sed -e 's/^shared,//'`      
  821.         ;;
  822.     *)
  823.         shared=no
  824.         ;;
  825.     esac
  826.     if test -n "$php_always_shared"; then
  827.         shared=yes
  828.     fi
  829. ])
  830.  
  831. dnl The problem is that the default compilation flags in Solaris 2.6 won't
  832. dnl let programs access large files;  you need to tell the compiler that
  833. dnl you actually want your programs to work on large files.  For more
  834. dnl details about this brain damage please see:
  835. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  836.  
  837. dnl Written by Paul Eggert <eggert@twinsun.com>.
  838.  
  839. AC_DEFUN(AC_SYS_LFS,
  840. [dnl
  841.   # If available, prefer support for large files unless the user specified
  842.   # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
  843.   AC_MSG_CHECKING(whether large file support needs explicit enabling)
  844.   ac_getconfs=''
  845.   ac_result=yes
  846.   ac_set=''
  847.   ac_shellvars='CPPFLAGS LDFLAGS LIBS'
  848.   for ac_shellvar in $ac_shellvars; do
  849.     case $ac_shellvar in
  850.       CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
  851.       *) ac_lfsvar=LFS_$ac_shellvar ;;
  852.     esac
  853.     eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
  854.     (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
  855.     ac_getconf=`getconf $ac_lfsvar`
  856.     ac_getconfs=$ac_getconfs$ac_getconf
  857.     eval ac_test_$ac_shellvar=\$ac_getconf
  858.   done
  859.   case "$ac_result$ac_getconfs" in
  860.     yes) ac_result=no ;;
  861.   esac
  862.   case "$ac_result$ac_set" in
  863.     yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
  864.   esac
  865.   AC_MSG_RESULT($ac_result)
  866.   case $ac_result in
  867.     yes)
  868.       for ac_shellvar in $ac_shellvars; do
  869.         eval $ac_shellvar=\$ac_test_$ac_shellvar
  870.       done ;;
  871.   esac
  872. ])
  873.  
  874. AC_DEFUN(AC_SOCKADDR_SA_LEN,[
  875.   AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
  876.     AC_TRY_COMPILE([#include <sys/types.h>
  877. #include <sys/socket.h>],
  878.     [struct sockaddr s; s.sa_len;],
  879.     [ac_cv_sockaddr_sa_len=yes
  880.      AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[ ])],
  881.     [ac_cv_sockaddr_sa_len=no])
  882.   ])
  883. ])
  884.  
  885.  
  886. dnl ## PHP_OUTPUT(file)
  887. dnl ## adds "file" to the list of files generated by AC_OUTPUT
  888. dnl ## This macro can be used several times.
  889. AC_DEFUN(PHP_OUTPUT,[
  890.   PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
  891. ])
  892.  
  893. AC_DEFUN(PHP_DECLARED_TIMEZONE,[
  894.   AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
  895.     AC_TRY_COMPILE([
  896. #include <sys/types.h>
  897. #include <time.h>
  898. #ifdef HAVE_SYS_TIME_H
  899. #include <sys/time.h>
  900. #endif
  901. ],[
  902.     time_t foo = (time_t) timezone;
  903. ],[
  904.   ac_cv_declared_timezone=yes
  905. ],[
  906.   ac_cv_declared_timezone=no
  907. ])])
  908.   if test "$ac_cv_declared_timezone" = "yes"; then
  909.     AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
  910.   fi
  911. ])
  912.  
  913. AC_DEFUN(PHP_EBCDIC,[
  914.   AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
  915.   AC_TRY_RUN( [
  916. int main(void) { 
  917.   return (unsigned char)'A' != (unsigned char)0xC1; 
  918. ],[
  919.   ac_cv_ebcdic="yes"
  920. ],[
  921.   ac_cv_ebcdic="no"
  922. ],[
  923.   ac_cv_ebcdic="no"
  924. ])])
  925.   if test "$ac_cv_ebcdic" = "yes"; then
  926.     AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
  927.   fi
  928. ])
  929.  
  930. AC_DEFUN(PHP_FOPENCOOKIE,[
  931.     AC_CHECK_FUNC(fopencookie, [ have_glibc_fopencookie=yes ])
  932.  
  933.     if test "$have_glibc_fopencookie" = "yes" ; then
  934.           dnl this comes in two flavors:
  935.       dnl newer glibcs (since 2.1.2 ? )
  936.       dnl have a type called cookie_io_functions_t
  937.           AC_TRY_COMPILE([ #define _GNU_SOURCE
  938.                        #include <stdio.h>
  939.                                        ],
  940.                        [ cookie_io_functions_t cookie; ],
  941.                      [ have_cookie_io_functions_t=yes ],
  942.                                          [ ] )
  943.  
  944.           if test "$have_cookie_io_functions_t" = "yes" ; then
  945.         cookie_io_functions_t=cookie_io_functions_t
  946.           have_fopen_cookie=yes
  947.       else
  948.           dnl older glibc versions (up to 2.1.2 ?)
  949.         dnl call it _IO_cookie_io_functions_t
  950.             AC_TRY_COMPILE([ #define _GNU_SOURCE
  951.                        #include <stdio.h>
  952.                                        ],
  953.                        [ _IO_cookie_io_functions_t cookie; ],
  954.                      [ have_IO_cookie_io_functions_t=yes ],
  955.                                          [] )
  956.             if test "$have_cookie_io_functions_t" = "yes" ; then
  957.           cookie_io_functions_t=_IO_cookie_io_functions_t
  958.             have_fopen_cookie=yes
  959.             fi
  960.             fi
  961.  
  962.           if test "$have_fopen_cookie" = "yes" ; then
  963.             AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
  964.               AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
  965.       fi      
  966.  
  967.       fi
  968. ])
  969.